import request from '@/utils/request'

export default {
  getList: function (params) {
    return request({
      url: '/shop/goods/list',
      method: 'get',
      params
    })
  },


  saveBaseInfo: function (params) {
    return request({
      url: '/shop/goods/saveBaseInfo',
      method: 'post',
      data: params
    })
  },
  save: function (params) {
    return request({
      url: '/shop/goods',
      method: 'post',
      data: params
    })
  },
  remove: function (id) {
    return request({
      url: '/shop/goods',
      method: 'delete',
      params: {
        id: id
      }
    })
  },
  get: function (id) {
    return request({
      url: '/shop/goods',
      method: 'get',
      params: {
        id: id
      }
    })
  },
  changeIsOnSale: function (id, isOnSale) {
    return request({
      url: '/shop/goods/changeIsOnSale',
      method: 'post',
      params: {
        id: id,
        isOnSale: isOnSale
      }
    })
  },
  apiUpdateStockSave: function (params) {
    return request({
      url: '/shop/goods/updateStock',
      method: 'post',
      params
    })
  },
  getAuditList: function (params) {
    return request({
      url: '/shop/goods/auditList',
      method: 'post',
      params: {
        createBy: params.createBy,
        isAudit: params.isAudit
      }
    })
  },

  changeIsAudit: function (id, isAudit) {
    return request({
      url: '/shop/goods/audit',
      method: 'post',
      params: {
        id: id,
        isAudit: isAudit
      }
    })
  },

  setWriteOffRate: function (params) {
    return request({
      url: '/shop/order/item/setWriteOffRate?goodsId=' + params.goodsId + '&rate=' + params.rate,
      method: 'post'
    })
  }
}
